﻿package Common 
{	
	import flash.geom.Point;
	import flash.utils.getDefinitionByName;
	
	public class UnitAbstract 
	{
		protected var FResourceName:String;
		protected var FGraphic:Vector.<Class>;		
		protected var FSize:int;
		protected var FOffsets:Vector.<Point>;
		protected var FScale:Number;
		
		public function UnitAbstract():void 
		{
			FOffsets = new Vector.<Point>;
			for (var i:int = 0; i < 4; i++)
				FOffsets.push(new Point());
			FGraphic = new Vector.<Class>;			
			FScale = new Number(1);
		}
		
		protected function LoadGraphic(ACollection:String, ACount:int):void
		{			
			for (var i:int = 0; i <  ACount; i++)
			{
				FGraphic.push(getDefinitionByName(ACollection + i) as Class);
			}
		}
		
		public function GraphicAt(AIndex:int):Class
		{
			return FGraphic[AIndex];
		}
		
		public function get ResourceName():String 
		{
			return FResourceName;
		}
		
		public function set ResourceName(AResourceName:String):void 
		{
			FResourceName = AResourceName;
		}
		
		public function get Size():int 
		{
			return FSize;
		}
		
		public function OffsetAt(AOrientation:int):Point
		{
			return FOffsets[AOrientation];
		}
		
		public function get Scale():Number
		{			
			return FScale;
		}
	}
}